<?php
//
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
if($_RQ['op']=='main'){
	$return['setting']=$this->plugin_setting('basic');
	$myshop = pdo_get('jy_commission_shop',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']));
	if(empty($myshop)){
		exi('还未拥有小店，移步创建！','error','/set/');
	}
	$return['params']=array();
	$return['params']['pid']=0;
	$return['list']=array();
	$params=array('uniacid'=>$_SESSION['uniacid'],'title <>'=>'','isshow'=>1,'parentid'=>0,'mid'=>0);
	if($_RQ['onepluginname']){
		$_SESSION['onepluginname']=$_RQ['onepluginname'];
	}
	$onepluginname=$_SESSION['onepluginname'];
	if($onepluginname){
		$params['onepluginname']=$onepluginname;
	}
	$groups=pdo_getall('jy_weishop_goods_group',$params,array('title','id'),'id','paixu desc');
	$myshop['groupset']=json_decode($myshop['groupset'],true);
	foreach($groups as &$item){
		$item['addfee']=$myshop['groupset'][$item['id']];
	}
	$return['groups']=$groups;
	$return['myshop']=$myshop;
	set_html('title','分类加价');
	exi($return);
}
if($_RQ['op']=='post'){
	$groups=get_postdata();
	$myshop = pdo_get('jy_commission_shop',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']));
	$groupset=json_decode($myshop['groupset'],true);
	foreach($groups as &$item){
		$groupset[$item['id']]=$item['addfee'];
	}
	$data=array(
		'groupset'=>ijson_encode($groupset),
	);
	pdo_update('jy_commission_shop',$data,array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']));
	exi('保存成功！','','goback');
}
?>